#include<iostream>
#include"mtsp.hpp"

using namespace std;
int *rand_array(int low, int high, int size){
    int *res = (int *)malloc(size * sizeof(int));
    if(res == nullptr){
        cout<<"Out Of Memory\n";
        exit(-1);
    }
    for(int i = 0; i < size; i++)res[i] = randint(low, high);

    return res;
}

template<typename T>
T **rand_matrix(int low, int high, int r, int c){
    T **res = (T **)malloc(sizeof(T *) * r);
    if(res == nullptr)return nullptr;

    int int_unit = sizeof(T);
    for(int i = 0; i < r; i++){
        T *pointer = (T *)malloc(int_unit * c);
        if(pointer == nullptr){
            cout<<"Out of Memory\n";
            exit(-1);
        }

        for(int j = 0; j < c; j++)pointer[j] = (T)randint(low, high);
        res[i] = pointer;
    }

    return res;
}

template<typename T>
void print_arr(T **m, int r, int c){
    cout<<"[";
    for(int i = 0; i < r; i++){
        cout<<"[";
        for(int j = 0;j < c; j++)cout<<m[i][j]<<" ";
        if(i < r - 1)cout<<"]\n";
        else cout<<"]";
    }
    cout<<"]\n";
}

template<typename T>
void print_arr(T *m, int size){
    cout<<"[";
    for(int j = 0;j < size; j++)cout<<m[j]<<" ";
    cout<<"]\n";
}


int main(){

    int node = 1000;
    int car = 50;
    int depot = 3;

    int population_num = 500;
    double mr = 0.8;
    unordered_map<int, int> car_depot;
    for(int i = 0; i < car; i++)car_depot[i] = randint(0, depot);

    double **graph = rand_matrix<double>(10, 15, node + depot, node + car - 1);

    Mtsp model(node, car, depot, car_depot, graph, population_num, mr);


    double res = model(10000, 30);

    return 0;
}